import xml.etree.ElementTree as ET
import sys

# 读取工作区文件
tree = ET.parse('CodeBlocks_wx30_64.workspace')
root = tree.getroot()

# 找到 Workspace 元素
workspace = root.find('Workspace')
if workspace is None:
    # 如果没有 Workspace 元素，创建一个
    workspace = ET.Element('Workspace')
    root.append(workspace)

# 添加新项目
new_project = ET.Element('Project', {'filename': 'tools/cbp2make_ai/cbp2make_aicoder.cbp'})
workspace.append(new_project)

# 保存文件
tree.write('CodeBlocks_wx30_64.workspace', encoding='UTF-8', xml_declaration=True)
